package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description NursingPlanController
 * @Author lwh
 * @Date 2025-05-08  17:33
 */
@RestController
@RequestMapping("/nursing")
@Api(tags = "护理计划")
public class NursingPlanController extends BaseController{

    @Autowired
    NursingPlanService nursingPlanService;

    @GetMapping("/plan")
    @ApiOperation(value = "查询所有护理计划")
    public ResponseResult getAllNursingPlans(){
        return success(nursingPlanService.getAllNursingPlans());
    }

    @PostMapping("/plan")
    @ApiOperation(value = "添加护理计划")
    public ResponseResult add(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.add(nursingPlanDto);
        return success();
    }

    @GetMapping("/plan/search")
    @ApiOperation(value = "分页查询护理计划")
    public ResponseResult<PageResponse<NursingPlanVo>> search(@RequestParam(defaultValue = "1") @ApiParam(value="当前页码") Integer pageNum,
                                              @RequestParam(defaultValue = "10") @ApiParam(value="每页条数") Integer pageSize,
                                              @RequestParam(required = false) @ApiParam(value="护理计划名称") String name,
                                              @RequestParam(required = false) @ApiParam(value="护理计划状态") Integer status){
        return success(nursingPlanService.page(pageNum, pageSize, name, status));
    }

    @GetMapping("/plan/{id}")
    @ApiOperation(value = "根据id查询护理计划")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Long id){
        return success(nursingPlanService.getById(id));
    }

    @PutMapping("/plan/{id}")
    @ApiOperation(value = "修改护理计划")
    public ResponseResult update(@PathVariable Long id,@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.update(id, nursingPlanDto);
        return success();
    }

    @DeleteMapping("/plan/{id}")
    @ApiOperation(value = "删除护理计划")
    public ResponseResult delete(@PathVariable Long id){
        nursingPlanService.delete(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "修改护理计划状态")
    public ResponseResult updateStatus(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.updateStatus(id, status);
        return success();
    }
}
